import os

DB_NAME = os.getenv("DB_NAME", "flask_example")
DB_USER = os.getenv("DB_USER", "dev")
DB_PASSWORD = os.getenv("DB_PASSWORD", "dev@123")
DB_HOST = os.getenv("DB_HOST", "10.211.55.4")
REDIS_HOST = os.getenv("REDIS_HOST", "10.211.55.4")
REDIS_PORT = os.getenv("REDIS_PORT", 6379)


# 编写默认配置类
class DefaultCongig:
    """默认配置
    数据库，redis的配置
    """

    # mysql配置
    SQLALCHEMY_DATABASE_URI = (
        f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:3306/{DB_NAME}"  # 连接地址
    )
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 是否追踪数据变化
    SQLALCHEMY_ECHO = False  # 是否打印底层执行的

    # redis相关配置,需要连接centos中的主库，info Replication
    REDIS_HOST = REDIS_HOST
    REDIS_PORT = REDIS_PORT

    # celery
    CELERY_BROKER_URL = f"redis://{REDIS_HOST}:6379/0"
    CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:6379/0"
    # admin
    FLASK_ADMIN_SWATCH = "cerulean"
    # JWT
    JWT_SECRET = "TPmi4aLWRbyVq8zu9v82dWYW17/z+UvRnYTt4P6fAXA"  # 秘钥
    JWT_EXPIRE_DAYS = 14  # JWT过期时间


config_dict = {"dev": DefaultCongig}
